function [Ytest, accuracy]=genlogit (Xtrain, Ytrain, Xtest, Ytesttrue)


B = mnrfit(Xtrain,Ytrain);
PHAT = mnrval(B,Xtest);

[Ygarbage, Ytest]=max(PHAT');
ind=find(Ytest'==Ytesttrue);
accuracy=100*size(ind,1)/size(Ytesttrue,1)
Ytest=Ytest';


Ntest=size(Xtest,1);
Clsno=size(unique(Ytrain),1);
temp=zeros(Ntest,Clsno);
temp  = temp';
temp2 = Ytest+Clsno*[0:Ntest-1]';
temp(temp2)=1;
Ytest = temp';


end

